package factory.one.command;

import com.alibaba.fastjson2.JSON;
import factory.one.entity.Order;
import factory.one.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author sk.z
 * 2023/7/5
 **/
@Service
public class CmdOrder {

    @Autowired
    private OrderService orderService;

    public void add(String code, String customId) {
        Order e = new Order();
        e.setCode(code);
        e.setCustomId(Long.valueOf(customId));
        e.setConfirm(false);
        e.setCreateTime(new Date());
        orderService.add(e);
    }

    public void list(String page, String size) {
        orderService.list(Integer.parseInt(page), Integer.parseInt(size)).forEach(e -> System.out.println(JSON.toJSONString(e)));
    }

    public void listCount(){
        System.out.println(orderService.listCount());
    }

}
